<?php

namespace common\models;

class Helper
{
    const KEY_STR = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzzx';
    public static function ht33(string $data, bool $nocare = FALSE): string
    {
        for ($hash = 5381, $i = strlen($data); $i; $hash = (($hash << 5) + $hash) + ord($data[--$i]) & 0xffffffffffff);
        if ($nocare) while ($i < 8) $code[] = self::KEY_STR[$hash >> $i++ * 5 & 31];
        else while ($i < 8) $code[] = self::KEY_STR[$hash >> $i++ * 6 & 63];
        return join($code);
    }
}
